﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace homework1
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow:Window
    {
        string lesson="",teacher="李四";

        public MainWindow()
        {
            InitializeComponent();
            ShowResult();
        }

        private void CourseClick(object sender,RoutedEventArgs e)
        {
            lesson="";
            foreach(var checkbox in CourseGrid.Children)
            {
                CheckBox checkBox=checkbox as CheckBox;
                if(checkBox!=null && checkBox.IsChecked==true)
                {
                    lesson+=checkBox.Content.ToString()+"、";
                }
            }

            lesson=lesson.TrimEnd('、');
            ShowResult();
        }

        private void ColorChecked(object sender,RoutedEventArgs e)
        {
            RadioButton button=e.Source as RadioButton;
            if(resultTextBlock!=null&&button!=null&&button.IsChecked==true)
                switch(button.Content.ToString())
                {
                    case"红色":
                        resultTextBlock.Foreground=Brushes.Red;
                        break;
                    case"蓝色":
                        resultTextBlock.Foreground=Brushes.Blue;
                        break;
                    case"黑色":
                        resultTextBlock.Foreground=Brushes.Black;
                        break;
                }
        }

        private void TeacherChanged(object sender,RoutedEventArgs e)
        {
            ComboBoxItem item=(sender as ComboBox).SelectedItem as ComboBoxItem;
            if(item.Content!=null)
            {
                teacher=item.Content.ToString();
                ShowResult();
            }
        }

        private void ShowResult()
        {
            if(resultTextBlock!=null)
                resultTextBlock.Text=$"教师：{teacher}  ,  课程：{lesson}";
        }
    }
}